package com.senlingspace.web.controller.headquarters;

import com.github.pagehelper.PageInfo;
import com.senlingspace.common.annotation.Log;
import com.senlingspace.common.core.controller.BaseController;
import com.senlingspace.common.core.page.TableDataInfo;
import com.senlingspace.common.enums.BusinessType;
import com.senlingspace.common.utils.poi.ExcelUtil;
import com.senlingspace.system.domain.SlkjOrder;
import com.senlingspace.system.domain.dto.FareSchemeRespDto;
import com.senlingspace.system.domain.vo.FareSchemeQueryVo;
import com.senlingspace.system.domain.vo.GoodsIncomeVo;
import com.senlingspace.system.domain.vo.TransactionVo;
import com.senlingspace.system.service.SlkjTransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;

/**
 *
 *
 * @author Administrator
 */
@RestController
@RequestMapping("/system/transaction")
public class SlkjTransactionController extends BaseController {

    @Autowired
    private SlkjTransactionService slkjTransactionService;


    @PreAuthorize("@ss.hasPermi('system:transaction:list')")
    @GetMapping("/list")
    public TableDataInfo list(Date startTime, Date endTime,Long shopId,String type,Integer source) {
        startPage();
        PageInfo<TransactionVo> list = slkjTransactionService.selectOrderTransaction(startTime,endTime,shopId,type,source);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('system:transaction:export')")
    @Log(title = "财务流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Date startTime, Date endTime,Long shopId,String type,Integer source) {
        List<TransactionVo> list = slkjTransactionService.exportOrderTransaction(startTime, endTime,shopId,type,source);
        ExcelUtil<TransactionVo> util = new ExcelUtil<>(TransactionVo.class);
        util.exportExcel(response, list, "财务流水数据");
    }
}
